package com.mycompany.user.controller;

import com.mycompany.user.entity.Permission;
import com.mycompany.user.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserAction {

	Logger logger = LoggerFactory.getLogger(UserAction.class);

	@Autowired
	private UserService userService;

	/**
	 * 用户注册
	 * @param
	 * @return
	 */
	@RequestMapping(value = "/userRegister",method = RequestMethod.POST)
	@ResponseBody
	public ModelAndView userRegister(HttpServletRequest request){
		return userService.userRegister(request);
	}

	/**
	 * 组织注册
	 * @param
	 * @return
	 */
	@RequestMapping(value = "/orgRegister",method = RequestMethod.POST)
	@ResponseBody
	public ModelAndView orgRegister(HttpServletRequest request){
		return userService.orgRegister(request);
	}

	/**
	 * 系统左侧菜单栏，不同用户显示不同的菜单栏
	 * @param
	 * @return
	 */
	@RequestMapping("/getAllPermission")
	@ResponseBody
	public List<Permission> getAllPermission(HttpServletRequest request){
		return userService.getAllPermission(request);
	}

}
